<?php
session_start();
ob_start('ob_gzhandler');
include_once('config.php');

if(@$_GET['danhmuc']){
	$dm = $_GET['danhmuc'];
	$dm = explode('/',$dm);
	$danhmuc = $dm[0];
	if($dm[1]=='') $page = 1; else $page = $dm[1];
	$menu_one = $tc->menu_one($danhmuc);
	$row_menu_one = mysql_fetch_array($menu_one);
	$idMenu = $row_menu_one['id'];
	$type = $row_menu_one['type_id'];
	if(!@$_GET['detail']){
		($row_menu_one['url_hinh']=='') ? $image='http://'.$domain.'/'.url_default_image : $image='http://'.$domain.'/'.url_danhmuc_image.$row_menu_one['url_hinh'];
		$url = 'http://'.$domain.'/'.$row_menu_one['url'];
		$seo = $tc->seo($domain,$row_menu_one['title'],$row_menu_one['metaDescription'],$row_menu_one['metaKeyword'],$image,$url);
		switch($type){
			case 2 : include_once('blocks/list_articles.php'); break;
			case 3 : include_once('blocks/list_product.php'); break;
			case 7 : include_once('blocks/contact.php'); break;
			default: $view_post = '<font color="#FF0000"><b>Could not be found</b></font>';
		}
	}else{
		$dt = $_GET['detail'];
		switch($type){
			case 2 : $detail = $tc->detail($dt); break;
			case 3 : $detail = $tc->detail_product($dt); break;
			default: $view_post = '<font color="#FF0000"><b>Could not be found</b></font>';
		}
		if($detail) $row_detail = mysql_fetch_array($detail);
		include_once('blocks/articles.php'); 
		($row_detail['url_hinh']!='') ? $image='http://'.$domain.'/'.url_detail_thumb_image.$row_detail['url_hinh'] : $image='http://'.$domain.'/'.url_default_image;
		$url = 'http://'.$domain.'/'.$row_menu_one['url'].$row_detail['name_rewrite'].'.html';
		$seo = $tc->seo($domain,$row_detail['name'],$row_detail['description'],$row_detail['metaKeyword'],$image,$url);
	}
}else{
	$menu_one = $tc->menu_one('trang-chu');
	$row_menu_one = mysql_fetch_array($menu_one);
	$url = 'http://'.$domain;
	($row_menu_one['url_hinh']=='') ? $image='http://'.$domain.'/'.url_default_image : $image='http://'.$domain.'/'.url_danhmuc_image.$row_menu_one['url_hinh'];
	$seo = $tc->seo($domain,$row_menu_one['title'],$row_menu_one['metaDescription'],$row_menu_one['metaKeyword'],$image,$url);
	include_once('blocks/home.php');
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php echo $seo; ?>
<link href="style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="library/jquery.js"></script>
<script type="text/javascript" src="website.js"></script>
<link href="assets/wt-rotator.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="assets/jquery.wt-rotator.min.js"></script>
<script type="text/javascript" src="assets/preview.js"></script>
</head>
<body>
<div id="wrapper">
	<?php
    include_once('blocks/header.php');
	include_once('blocks/menu.php');
	include_once('blocks/slider.php');
	?>
    <?php if($danhmuc!='') echo $tc->navigator($row_menu_one['url'],$row_menu_one['name'],$row_menu_one['title']); else echo '<div style="clear:both; height:30px"></div>';?>
	<div id="content">
    	<?php
        include_once('blocks/left.php');
		echo '<div id="right_view">'.$view_post.'</div>';
		?>
    </div>
    <?php include_once('blocks/partner.php');?>
</div>
<?php
/*Footer*/
$view_foo = '<div id="footer">
	<div style="width:1000px; margin:auto">
		<div style="width:auto; float:left">'.$row_config['footer'].'</div>
		<div id="menu_foo">';
$m_foo = $tc->menu(0,2);
while($row_foo = mysql_fetch_array($m_foo)){
	$view_foo .= '<a href="'.$row_foo['url'].'">'.$row_foo['name'].'</a>';
}
$view_foo .= '</div><div style="clear:both; height:1px"></div></div></div>';
echo $view_foo;

include_once('blocks/qc2ben.php');
?>
<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-43258730-1', 'muabannhadathcm.com');
  ga('send', 'pageview');

</script>
</body>
</html>